/**
 * 产品表
 */
module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, DATE, STRING, TEXT } = Sequelize;

    await queryInterface.createTable('product', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      uuid: { type: STRING(36), unique: true },
      name: STRING(50),
      model: STRING(50), // 产品型号
      productNo: STRING, // 产品编号（可唯一确定产品信息）
      registrationStatus: STRING(50), // 注册情况（可选：已注册/未注册）
      address: STRING(255), // 产品地址（用户输入）
      unit: STRING(255),
      fk_applicationArea: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'application_area',
          },
          key: 'uuid',
        },
      }, // 应用领域（外键：application_area）'，外键
      patent: STRING(255), // 所用成果
      description: TEXT,
      updateTime: DATE,
      filler: {
        type: STRING(36),
      }, // 填写人
      contactTel: STRING(50), // 联系人电话
      contactPerson: STRING(10), // 联系人姓名
      contactEmail: STRING(50), // 联系人email
      createdAt: DATE,
      updatedAt: DATE,
    });
  },

  down: async queryInterface => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('product');
  },
};
